-
Notifications
You must be signed in to change notification settings - Fork 16.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add yaw recovery that uses only IMU and GPS data #13603
Conversation
After discussions with Tridge, it makes sense for this to go into a separate library that can be used by both EKF2 and EKF3. The use by each estimator core should be controllable by a parameter enabling it to be set to off, ride-along, active (able to be used by resets) and any other use options. |
c9ed538
to
066271b
Compare
The following graphs are from testing performed using a quadplane. This platform type enables both copter and fixed wing flight motion characteristics to be tested. For this test the number of filter banks was set to 5. A vertical takeoff was performed in QLOITER followed by a transition to horizontal flight in CRUISE. GSF0.Y0 ... GSF0.Y4 show the yaw estimate from each of the 3-state EKF's. GSF0.YC is the composite yaw output from the Gaussian Sum Filter (GSF) which combines the yaw estimates from each 3-state EKF. For comparison the yaw estimate from the EKF3 is also shown. The GSF yaw starts to converge during the initial climb in QLOITER due to the small amount of horizontal motion and then rapidly finalises the convergence when the transition manouevre starts. Here are the weights calculated by the GSF and used to combine the individual yaw outputs from the 3-state EKF's. Also plotted is the estimated 1-Sigma yaw uncertainty for the GSF output in degrees. Here is the ground speed: The centripetal acceleration compensation using airspeed appears to be working effectively with the GSF yaw estimate closely tracking the EKF3 yaw through fixed wing flight. |
In addition to the flight test result presented above, another three flights with vertical takeoffs were performed with similar characteristics. The yaw partially converges during the vertical climb due to residual horizontal motion and rapidly completes convergence during transition to forward flight. |
SITL test results for patch b947374 which eliminates the use of quaternions. This change was inspired by the old DCM algorithm. |
@tridge I've moved it into a separate class but still need to add it to EKF2. |
Todays testing performed using a quadplane in both RW and FW flight modes: A total of 5 RW->FW transitions were performed across two flights. The first flight was with only 1 instance of EKF3 running using IMU1 (EK3_IMU_MASK = 1), the second flight used two instances (EK3_IMU_MASK = 3) Flight 1: https://drive.google.com/open?id=19oji0tqwpPHhY5Uya-NxSKO_tK0TsDOq The following plots shows a vertical takeoff with transition into forward flight from flight 2: As per previous testing there is enough horizontal motion during the vertical climb to enable the GSF to correctly estimate the yaw immediately after takeoff although reported uncertainty for the GSF yaw estimate stays around close to radians until forward transition enables the estimate to be improved. |
2dd1ff7
to
089c807
Compare
Enable recovery from an EKF navigation failure caused by a bad yaw estimate.
Handle case where no airspeed sensor is fitted or airspeed data stops
Remove weighting function lower limit control. Fix bug causing multiple alignments of each AHRS filter
Fixes a race condition that was causing the Copter EKF failsafe triggering after a successful reset.
Increases learned gyro bias saturation level from 3 to 5 deg/sec
Improve variable naming and consolidate GSF data into a struct.
Fix bug where AHRS gain was not updated if outside min/max accel. Eliminate unnecessary conversions from accel to 'g'.
Enable the number of filters to be adjusted. Enable the default airspeed used for centripetal acceleration compensation in fixed wing operation to be adjusted.
The propagation of the gyro delta angle and corrections is performed directly on the rotation matrix using a small angle approximation. This is similar to the approach used by the AHRS legacy Dcm algorithm. This has enabled the elimination of the quaternion states and a significant amount of unnecessary conversions between quaternions and other orientation descriptors.
I think it was probably just the EKF3 failing GPS innovation checks. When the GPS is reporting good accuracy, it only takes a few metres of movement for the 5-sigma consistency check to fail. I assume you ended up placing the vehicle at the takeoff location before applying power. |
SITL Copter flyaway test of commit 19edca7 |
It is better to keep old weights. The determinant calculation can handle a smaller determinant than previously allowed for.
Weights from test of b23f342 |
Thank you rmackay9 for posting the flight test video https://www.youtube.com/watch?v=3xW9hj-lxNU |
Comments other than this one have been addressed to the best of my knowledge. Moving this into a separate library with its own buffers for IMU and GPS is going to increase flash space unless we also move the IMU and GPs read and buffering into a template class to avoid another duplicate of the readGPSdata and readIMUdata functionality that is already replicated in EKF2 and EKF3. Doing this is beyond the time I have available for this task at this point in time and should be tackled in a separate PR. Once this PR is in I can then then get the functionality into EKF2. |
Testing at commit 6fc86ba using ArduPlane SITL used a takeoff with a 180 deg yaw error, tripping the yaw reset using the RC channel option and placing the vehicle into a loiter to monitor the centripetal accel correction. The airspeed sensor use was then stopped via the USE_ARSPEED parameter which forced the EKF to use the default value which is halfway between min and max param values. This resulted in a small increase in the velocity innovations for the 3-state filter banks, but yaw estimation remained acceptable.: Edit: investigating the airspeed estimate received by the yaw estimator showed that there was a cm/s vs m/s error in ArduPlane.cpp where the default airspeed value was written. This has been fixed by 9e2abfa See: |
Removes unnecessary use of memcpy. Documentation and code style fixes.
This better matches what current generation HW is able to support under typical flight conditions.
Today I was able to run multiple flight tests including the latest commits Here is data from one of the flights - log here Taking off in loiter mode, the EKF yaw reset 5m from the takeoff location and the fly-away arrested at 7m. The vehicle was recovered in RTL. GPS ground track (yellow square is 10x10m) Here are the yaw estimates - note the EKF3 yaw (yellow line) resets to the GSF estimate at 17:55:51 when the GSF's reported yaw uncertainty drops below 15 degrees which is the exisiting threshold requirement for the EKF3 to use the GSF yaw estimate. Here are the GSF calculated weights for the individual yaw estimates: Here are the EKF3 GPS velocity innovations - note the immediate reduction in levels after the yaw reset at 17:55:51 |
Note to self: remember to revert the changes to COMPASS_ORIENT before the next flight or your copter will come home in many pieces. :-) |
Two small things:
|
Have squashed commit history and continued here: #13776 |
This PR implements a prototype multiple hypothesis estimation algorithm that enables recovery from an EKF3 navigation failure caused by a bad yaw estimate.
This is the culmination of algorithm development work that was first presented at the ArduPilot Un-Conference in 2018. See time 35:34 in the following presentation https://www.youtube.com/watch?v=XCl1Md-2Epc
In summary:
The Matlab derivation and scripts are available here: https://github.com/priseborough/3_state_filter.
The following SITL test results were obtained using the SITL ArduCopter simulation with the following parameter changes from the defaults:
EK2_ENABLE = 0
EK3_ENABLE = 1
AHRS_EKF_TYPE = 3
EKF_IMU_MASK = 1 (done to reduce log size and number of console messages during algorithm testing)
The SIM_Aircraft.cpp file was modified as shown below to induce over 90 degrees of initial heaidng error:
The following plot shows how the bank of 8 EKF filters and the weighted average generated by the Gaussian Sum Filter (GSF) converges within 2 seconds of the flyaway commencing. The reset of the main navigation filter yaw can be seen:
The following figure shows the weights calculated by the GSF and used to form the weighted average yaw output. It also shows the estimated yaw uncertainty (square root of the variance):
TODO
Follow On Work
This work is best done in separate pull requests and includes: